package cn.bytecollege.controller;

import cn.bytecollege.constant.Resource;
import cn.bytecollege.entity.Page;
import cn.bytecollege.entity.UserManage;
import cn.bytecollege.service.UserMessageService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UserMessageListController", value = "/userMessageList")
public class UserMessageListController extends HttpServlet {
    UserMessageService userMessageService=null;
    public  UserMessageListController(){
        userMessageService=new UserMessageService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String index=request.getParameter("index");
        String size=request.getParameter("size");
        int pageIndex=(index==null)?1:Integer.valueOf(index);
        int pageSize=(size==null)?5:Integer.valueOf(size);
        Page<UserManage> page=userMessageService.findListByPage(pageIndex,pageSize,1);
        request.setAttribute("page",page);
        request.getRequestDispatcher(Resource.PAGE_LOCATION+"/userMessageList.jsp").forward(request,response);
    }
}
